//
//  CreateChatRoomViewController.m
//  LiaoTianShi
//
//  Created by lanou3g on 15/11/10.
//  Copyright © 2015年 菲克. All rights reserved.
//

#import "CreateChatRoomViewController.h"

#import "ChatModel.h"
#import <AVOSCloudIM.h>
#import <AVOSCloud.h>

#import "CHATViewController.h"
@interface CreateChatRoomViewController ()

@end

@implementation CreateChatRoomViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (IBAction)createRoom:(id)sender {
    AVUser * curUser = [AVUser currentUser];
    
    // 创建房间.
    ChatModel * cr = [ChatModel shareChatRoomHandle];
    [cr createRoomWithClientID:curUser.username RoomName:self.roomName.text callback:^(BOOL success, NSError *error) {
        if (success) {
            // 可以进入聊天室
            NSLog(@"可以进入聊天室");
           CHATViewController * chatRoomVC = [[CHATViewController alloc] init];
            
            [self.navigationController pushViewController:chatRoomVC animated:YES];
        }
    }];
    // [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
